<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('合同列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>

                        <!--                            <li class="select-time">-->
                        <!--                                <p>合同开始时间：</p>-->
                        <!--                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginStartTime]"/>-->
                        <!--                                <span>-</span>-->
                        <!--                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endStartTime]"/>-->
                        <!--                            </li>-->
                        <!--                            <li class="select-time">-->
                        <!--                                <p>合同结束时间：</p>-->
                        <!--                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginEndTime]"/>-->
                        <!--                                <span>-</span>-->
                        <!--                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endEndTime]"/>-->
                        <!--                            </li>-->


                        <li>
                            <p>公司名称：</p>
                            <input type="text" name="corporateName"/>
                        </li>
                        <!--                            <li>-->
                        <!--                                <p>固定电话：</p>-->
                        <!--                                <input type="text" name="telephone"/>-->
                        <!--                            </li>-->
                        <p>合同状态：</p>
                        <select name="contractStart" th:with="type=${@dict.getType('')}">
                            <option value="">所有</option>
                            <option value="0">有效</option>
                            <option value="1">以过期</option>
                            <option value="2">无效</option>
                            <!--                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
                            <!--                                    th:value="${dict.dictValue}"></option>-->
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="mall:contract:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="mall:contract:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="mall:contract:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mall:contract:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('mall:contract:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mall:contract:remove')}]];
    var prefix = ctx + "mall/contract";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "【请填写功能名称】",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'contractId',
                    title: '合同id'
                },

                {
                    field: 'corporateName',
                    title: '公司名称'

                },
                {
                    field: 'startTime',
                    title: '合同开始时间'
                },
                {
                    field: 'endTime',
                    title: '合同结束时间'
                },
                {
                    field: 'contractImg',
                    title: '合同扫描件'
                },
                {
                    field: 'bank',
                    title: '开户行'
                },
                {
                    field: 'bankNumber',
                    title: '开户账号'
                },
                {
                    field: 'phone',
                    title: '手机号码'
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'telephone',
                    title: '固定电话'
                },
                {
                    field: 'email',
                    title: '邮箱'
                },
                {
                    field: 'contractStart',
                    title: '合同状态',
                    formatter: function (value, row, index) {
                        if (row.contractStart === 0) {
                            return "正常";
                        } else if (row.contractStart === 1) {
                            return "过期";
                        } else {
                            return "失效";
                        }
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="dtailsUrl(\'' + row.id + '\')">详情</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')">编辑</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="Renew(\'' + row.id + '\')">续签</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function edit(id) {
        $.modal.open("编辑合同", prefix + "/edit?id=" + id);
    }

    function dtailsUrl(id) {
        $.modal.open("合同详情", prefix + "/viewContract?id=" + id);
    }

    function Renew(id) {
        $.modal.open("合同续签", prefix + "/renew?id=" + id);
    }

</script>
</body>
</html>